<!-- 新增申领-1 -->
<template>
	<view>
		<view class="p-3">
			<view class="bt-block">
				<bg-title class="margin-top mx-3">
					<text class="font-14 font-normal">工资支付单</text>
				</bg-title>
				<view class="font-13 p-3">
					<bg-desc class="margin-bottom-lg" label="项目名称"  :value="obj.projectName"></bg-desc>
					<bg-desc class="margin-tb-lg" label="姓名"  :value="obj.userName"></bg-desc>
					<bg-desc class="margin-tb-lg" label="身份证号"  :value="obj.idCardNo"></bg-desc>
					<bg-desc class="margin-tb-lg" label="手机号"  :value="obj.phone"></bg-desc>
					<bg-desc class="margin-tb-lg" label="银行卡号"  :value="obj.bankCardNo"></bg-desc>
					<bg-desc class="margin-tb-lg" label="开户行"  :value="obj.bankName"></bg-desc>
					<bg-desc class="margin-tb-lg" label="工种"  :value="obj.workJob"></bg-desc>
					<bg-desc class="margin-tb-lg" label="出勤"  :value="obj.attendanceDays"></bg-desc>
					<bg-desc class="margin-tb-lg" label="日工资"  :value="obj.daySalary"></bg-desc>
					<bg-desc class="margin-tb-lg" label="加班费"  :value="obj.overtimeSalary"></bg-desc>
					<bg-desc class="margin-tb-lg" label="扣款项(劳保款)"  :value="obj.workWearAmount"></bg-desc>
					<!-- <bg-desc class="margin-tb-lg" label="合计支付工资金额"  :value="obj.salaryAmount" :valueStyle="{'color':'#EE3636'}"></bg-desc> -->
					<bg-desc class="margin-tb-lg" label="合计支付工资金额"  :value="obj.actualAmount" :valueStyle="{'color':'#EE3636'}"></bg-desc>
				</view>
			</view>
			<view class="bt-block mt-3">
				<bg-title class="margin-top mx-3">
					<text class="font-14 font-normal">本人确认签字</text>
				</bg-title>
				<view class="p-3">
					<bg-sign @sign-success="SignHandler"></bg-sign>
				</view>
			</view>
		</view>
		<view class="bt-footer">
			<bg-btn @click="toApply">申请支付</bg-btn>
		</view>
	</view>
	
</template>

<script>
	import { salaryToApply, salaryApply } from '../../../api/salary'
	export default {
		data() {
			return {
				obj:{},
				postData:{
					"projectId": 0,
					  "userId": 0,
					  "salaryAmount": 0,
					  "status": "",
					  "salaryId": 0,
					  "signedImg": ""
				},
			}
		},
		mounted() {
			this.getData()
		},
		methods: {
			getData(){
				salaryToApply().then(res=>{
					if(res.data){
						this.obj = res.data
						this.postData.userId = this.obj.userId
						this.postData.projectId=this.obj.projectId
						this.postData.salaryAmount = this.obj.salaryAmount
						this.postData.salaryId =   this.obj.salaryId
						
					} else {
						this.$modal.confirm("暂无可申领的工资", false).then(res=>{
							uni.navigateBack()
						})
					}
					
				})
			},
			toApply(){
				if(!this.postData.signedImg){
					this.$modal.msg("请签字")
					return false
				}
				salaryApply(this.postData).then(res=>{
					this.$modal.msg("申请成功，该工资将在7个工作日内到账，请及时查收")
					uni.$emit("refresh-page", true)
					this.$tab.navigateBackDelay()
				})
			},
			SignHandler(e){
				console.log(e)
				this.postData.signedImg = e.fileName
			},
		}
	}
</script>

<style>

</style>
